package com.wutong.erb.util;

import com.wutong.erb.other.CookieBuilder;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;

/**
 * Cookie工具类
 * @author wutong
 */
public class CookieUtil {
    public static Cookie getCookie(HttpServletRequest request, String cookieName) {
        Cookie[] cookies = request.getCookies();
        if (cookies!= null) {
            for (Cookie cookie : cookies) {
                if (cookie.getName().equals(cookieName)) {
                    return cookie;
                }
            }
        }
        return null;
    }

    public static CookieBuilder createCookie(String name, String value) {
        return new CookieBuilder(name, value);
    }
}
